package sword_offer;

/**
 * @author Synhard
 * @version 1.0
 * @Class sword_offer.Code24
 * @Description 定义一个函数，输入一个链表的头节点，反转该链表并输出反转后链表的头节点。
 * @tel 13001321080
 * @email 823436512@qq.com
 * @date 2021-03-16 10:48
 */
public class Code24 {
    public ListNode reverseList(ListNode head) {
        if (head == null || head.next == null) {
            return head;
        }
        ListNode res = reverseList(head.next);
        head.next.next = head;
        head.next = null;
        return res;
    }
}
